package com.me.shop.adminuser.action;

import org.apache.struts2.ServletActionContext;

import com.me.shop.adminuser.bean.AdminUser;
import com.me.shop.adminuser.service.AdminUserService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class AdminUserAction extends ActionSupport implements ModelDriven<AdminUser>{
	private AdminUserService adminUserService;

	public void setAdminUserService(AdminUserService adminUserService) {
		this.adminUserService = adminUserService;
	}
	
	private AdminUser adminUser = new AdminUser();
	public AdminUser getModel() {
		return adminUser;
	}
	
	public String login() {
		AdminUser existAdminUser = adminUserService.login(adminUser);
		if(existAdminUser == null) {
			this.addActionError("用户名或密码错误");
			return "loginFail";
		} else {
			ServletActionContext.getRequest().getSession().setAttribute("existAdminUser", existAdminUser);
			return "loginSuccess";
		}

	} 
	
	
	
}





















